<template>
  <section>


    <!--工具条-->
    <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
      <el-form :inline="true" :model="query">
        <el-form-item>
          <el-input v-model="query.keyword" placeholder="员工姓名"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="getQueryEmployees">查询</el-button>
        </el-form-item>
      </el-form>
    </el-col>
    <!--列表-->
    <el-table :data="this.pageInfo.dataList" highlight-current-row v-loading="listLoading"  style="width: 100%;">

      <el-table-column type="selection" width="55">
      </el-table-column>
      <el-table-column type="index" width="60">
      </el-table-column>
      <!--      width="120" sortable-->


      <el-table-column prop="noteContent" label="修改内容">
      </el-table-column>

      <el-table-column prop="createTime" label="修改时间">
      </el-table-column>

      <el-table-column prop="employee.name" label="修改人">
      </el-table-column>


    </el-table>



  </section>
</template>

<script>



export default {
  data() {
    return {




      query: {
        keyword: '',
        currentPage:1,
        pageSize:10
      },
      pageInfo:{
        dataList: [],
        total: 0
      },
      page: 1,
      listLoading: false,
      sels: [],//列表选中列

      editFormVisible: false,//编辑界面是否显示
      editLoading: false,
      editFormRules: {
        name: [
          { required: true, message: '请输入姓名', trigger: 'blur' }
        ]
      },

      saveFormVisible: false,//新增界面是否显示
      addLoading: false,
      saveFromRules: {
        name: [
          { required: true, message: '请输入姓名', trigger: 'blur' }
        ]
      },





      //
      deptFrom: {
        id:null,
        name: "",
        intro:"",
        manager:{
          id:null,
          username:""
        },
        parent:{
          id:null,
          name:""
        },
        state:""
      },
    }
  },
  methods: {


    //全选
    handleCheckAllChange(val) {
      this.checkedRoles = val ? this.allChecked : [];
      this.isIndeterminate = false;
    },
    handleCheckedCitiesChange(value) {
      let checkedCount = value.length;
      this.checkAll = checkedCount === this.roleList.length;
      this.isIndeterminate = checkedCount > 0 && checkedCount < this.roleList.length;
    },

    //显示
    handleRole: function (index, row) {

      this.getRoleList()
      this.employeeRole.employeeId= row.id


    },
    


    //--------------------------------------------------------------
    handleSizeChange(val){
      this.query.pageSize = val;
      this.getActivityRemarks()
    },
    // 点击查询按钮
    getQueryEmployees(){
      this.query.currentPage = 1
      this.getActivityRemarks()
    },
    //性别显示转换
    formatSex: function (row, column) {
      return row.sex == 1 ? '男' : row.sex == 0 ? '女' : '未知';
    },
    handleCurrentChange(val) {
      this.query.currentPage = val;
      this.getActivityRemarks()
    },
    
    //获取全部配置列表
    getActivityRemarks() {
      // No 'Access-Control-Allow-Origin'
      // 只要看到浏览器报这个错误就是跨域问题 前后端分离的项目一定会有跨越问题
      this.listLoading = true;
      // 发请求
      // localhost:8080/employee  全局的前缀
      this.$http.put("/activityRemark",this.query)
          .then(result=>{
            result = result.data
            if (result.success){
              this.$message({message: '查询成功', type: 'success' });
              this.listLoading = false;
              this.pageInfo = result.resultObj
              console.log(this.pageInfo.dataList);
            }else{
              this.$message({message: '查询失败', type: 'danger' });
            }
          })
          .catch(result=>{

          })

    },



    //显示新增界面
    handleAdd: function () {
      this.saveFormVisible = true;
      this.getActivityRemarks()

      this.saveFrom = {
        id:null,
        key:"",
        value:"",
        type:"",
        intro:""
      };

    },
    //编辑

    ///-----------------------------------------------------
    //新增  / 修改
    addSubmit: function () {
      this.$refs.saveFrom.validate((valid) => {
        if (valid) {
          this.$confirm('确认提交吗？', '提示', {}).then(() => {
            this.addLoading = true;
            //NProgress.start();
            let para = Object.assign({}, this.saveFrom);
            console.log(para);


            this.$http.post("/activityRemark",para)
                .then(result=>{
                  result = result.data
                  if (result.success){
                    this.$message({message: '保存成功', type: 'success' });
                    this.addLoading = false;
                    this.saveFormVisible=false; //成功关闭窗口
                    this.query.currentPage = 1;
                    // 刷新列表
                    this.getActivityRemarks()
                  }else{
                    this.$message({message: '保存失败', type: 'danger' });
                    this.addLoading = false;
                  }
                })
                .catch(result=>{
                  this.$message({message: '网络故障', type: 'danger' });
                  this.addLoading = false;
                })
          })
              .catch(() => {
                this.$message({message: '网络故障', type: 'danger' });
                this.addLoading = false;
              });

        }
      });
    },
    selsChange: function (sels) {
      this.sels = sels;
    },

    //批量删除
    batchRemove: function () {
      var ids = this.sels.map(item => item.id);
      this.$confirm('确认删除选中记录吗？', '提示', {
        type: 'warning'
      }).then(() => {
        this.listLoading = true;
        // 发请求
        this.$http.patch("/activityRemark",ids)
            .then(result=>{
              result = result.data
              if (result.success){
                this.$message({message: '批量删除成功', type: 'success' });
                this.listLoading = false;
                this.query.currentPage = 1;
                // 刷新列表
                this.getActivityRemarks()
              }else{
                this.$message({message: '批量删除失败', type: 'danger' });
              }
            })
            .catch(result=>{

            })
      })
          .catch(() => {

          });
    },


  },
  mounted() {
    this.getActivityRemarks();

  }
}

</script>

<style scoped>

</style>